<template>
  <section class="navBar-wrapper">
    <!-- 安全运行天数 -->
    <!-- <div class="runTime-box">
      <span>安全运行</span>
      <ul class="runTime-list-box">
        <li
          class="runTime-list-item"
          v-for="(item, index) in countTime"
          :key="index"
        >
          {{ item }}
        </li>
        <span>天</span>
      </ul>
    </div> -->
    <div class="time-box">
      <p class="hour-box">{{ times.time }}</p>
      <p class="date-box">
        {{ times.day }}
        <span>{{ times.week }}</span>
      </p>
    </div>
    <!-- 中间部分，标题+菜单 -->
    <div class="navbar-title-box">
      <!-- 标题部分 -->
      <div class="navbar-title">
        <div style="margin-left: -20px">
          <!-- <p class="one-title" v-html="systemName"></p> -->
          <p class="one-title">{{ title }}</p>
        </div>

        <!-- 菜单部分 -->
        <section class="menu-box">
          <!-- 左边菜单部分 -->
          <section class="menu-left">
            <menu-list
              :menulist="menulist.slice(0, Math.ceil(menulist.length / 2))"
            />
          </section>
          <!-- 右边菜单部分 -->
          <section class="menu-right">
            <menu-list
              :menulist="
                menulist.slice(Math.ceil(menulist.length / 2), menulist.length)
              "
            />
          </section>
        </section>
      </div>
    </div>
    <!-- 右边部分 -->
    <section class="narbar-right">
      <!-- 系统消息+用户下拉 -->
      <div class="icon-box">
        <router-link to="/warning">
          <a-badge :count="alarmCount">
            <a-icon type="bell" />
          </a-badge>
        </router-link>
      </div>
      <!-- 用户信息 -->
      <div class="user-info">
        <svg-icon iconClass="defaultUser" class="head-icon"></svg-icon>
        <span @click="() => (dropDownShow = !dropDownShow)">
          <span class="user-name">user</span>
          <a-icon type="down" class="down-icon" />
        </span>

        <!-- 下拉框 -->
        <ul class="dropDown-box" v-if="dropDownShow">
          <li class="list-item" @click="logout">注销</li>
          <li class="list-item" @click="toSystem">切换后台</li>
        </ul>
      </div>
    </section>
  </section>
</template>

<script>
import menuList from "../components/menuList.vue";
import moment from "moment";
export default {
  name: "NavBar",
  components: { menuList },
  data() {
    return {
      systemName: "",
      countTime: ["1", "2"],

      times: {
        time: moment(new Date()).format("HH:mm:ss"),
        day: moment(new Date()).format("YYYY/MM/DD"),
        week: moment(new Date()).format("dddd"),
      },
      alarmCount: 100,
      dropDownShow: false,
      searchVal: "",
      locationTimer: null,
      menulist: [
        { key: "1", path: "/home", label: "配网停运" },
        {
          key: "2",
          path: "/home",
          label: "停电时户",
          children: [
            { key: "2-1", path: "/home", label: "动环监控" },
            { key: "2-2", path: "/home", label: "视频监控" },
          ],
        },
        { key: "3", path: "/home", label: "运险投诉" },
        {
          key: "4",
          path: "/home",
          label: "配网异常",
          children: [
            { key: "4-1", path: "/home", label: "当前告警" },
            { key: "4-2", path: "/home", label: "历史告警" },
          ],
        },
        { key: "5", path: "/home", label: "抢救工单" },
        { key: "6", path: "/home", label: "终端展示" },
      ],
      title: "配网全景展示平台",
    };
  },
  created() {
    this.getLocationTime();
  },
  methods: {
    moment,
    // 获取当前时间
    getLocationTime() {
      this.locationTimer = setInterval(() => {
        this.times.time = moment(new Date()).format("HH:mm:ss");
        this.times.day = moment(new Date()).format("YYYY/MM/DD");
        this.times.week = moment(new Date()).format("dddd");
      }, 1000);
    },
  },
};
</script>

<style lang="scss">
// 媒体查询的参数
$type: screen;
$proto: max-width;
$value: 1740px;
$navbarHeight: 60px;
$navbarTitleWidth: 600px;
$smallNavbarTitleWidth: 540px;
$navbarTitleHeight: 70px;
$navbarHeight: 60px;
$timeBoxHeight: 40px;
$inputColor: #92c9f3;
$inputHeight: 26px;
// 菜单整体布局宽度
$runTimeWidth: 260px;
$menuWidth: 1400px;
$smallMenuWidth: 1100px;
$rightWidth: calc(100% - #{$runTimeWidth} - #{$menuWidth});
//特殊字体定义
// @font-face {
//     font-family: "ds-digitalnormal";
//     src: url("../assets/font/ds-digi-webfont.eot");
//     src: url("../assets/font/ds-digi-webfont.eot?#iefix")
//             format("embedded-opentype"),
//         url("../assets/font/ds-digi-webfont.woff") format("woff"),
//         url("/assets/font/ds-digi-webfont.svg#ds-digitalnormal") format("svg");
//     font-weight: normal;
//     font-style: normal;
// }
.center {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
}
.navBar-wrapper {
  display: flex;
  width: 100%;
  height: $navbarHeight;
  // background: url("../assets/images/navbarBg1.png") no-repeat;
  // background-size: 100% 100%;
  background:#092047;
  .time-box {
    color: #fff;
    min-width: 100px;
    text-align: center;
    line-height: 1.6;
    margin: 10px 10px 0;
    @media #{$type} and ($proto: $value) {
      font-size: 12px;
    }
    .hour-box {
      font-family: "ds-digitalnormal";
      font-size: 18px;
      color: #00f6ff;
      font-weight: bold;
      letter-spacing: 7px; //9px
      margin-right: -8px;
      @media #{$type} and ($proto: $value) {
        letter-spacing: 9px;
        margin-top: 6px;
        font-size: 14px;
      }
    }
    .date-box {
      display: flex;
      font-size: 14px;
      span {
        margin-left: 4px;
      }
      @media #{$type} and ($proto: $value) {
       font-size: 13px;
       span {

        margin-left: 14px;
      }
      }
    }
  }

  // 中间部分
  .navbar-title-box {
    position: relative;
    width: $menuWidth;
    height: $navbarTitleHeight;
    background: url("../assets/images/navbarTitleBg1.png") no-repeat;
    background-size: 100% 100%;
    margin: 0 auto;
    @extend .center;
    @media #{$type} and ($proto: $value) {
      width: $smallMenuWidth;
    }
    .navbar-title {
      height: $navbarTitleHeight;
      width: $navbarTitleWidth;
      padding-top: 18px;
      color: #fff;
      font-size: 18px;
      text-align: center;
      letter-spacing: 6px;
      font-weight: bold;
      @extend .center;
      left: 50px;
      @media #{$type} and ($proto: $value) {
        width: $smallNavbarTitleWidth;
        font-size: 16px;
        letter-spacing: 4px;
        line-height: 1.8;
      }
    }
    .menu-box {
      height: 100%;
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
      .menu-left {
        position: absolute;
        left: -$navbarTitleWidth/2  - 60px;;
        bottom: 16px;
        @media #{$type} and ($proto: $value) {
          left: -$smallNavbarTitleWidth/2 + 100px;
        }
      }
      .menu-right {
        position: absolute;
        right: -$navbarTitleWidth/2;
        bottom: 16px;
        span{
          margin-left:20px;
        }
        @media #{$type} and ($proto: $value) {
          right: -$smallNavbarTitleWidth/2 + 80px;
        }
      }
    }
  }
  // 右边部分
  .narbar-right {
    display: flex;
    text-align: right;
    position: absolute;
    right: 0;
    min-width: 100px;
    // max-width: 400px;
    height: $navbarHeight;
    // overflow-x: auto;
    // overflow-y:hidden;
    .search-box {
      width: 120px;
      margin-right: 20px;
      @media #{$type} and ($proto: $value) {
        margin-right: 10px;
      }

      .ant-input-prefix {
        color: $inputColor;
        margin-right: 10px;
      }
      .ant-input-affix-wrapper {
        margin-top: 14px;
        border-radius: 20px;
        border: 1px solid $inputColor;
        background: transparent;
        @media #{$type} and ($proto: $value) {
          height: 30px;
          margin-top: 18px;
        }
        .ant-input {
          background: transparent;
          color: $inputColor;
          border: 0;
          height: $inputHeight;
          line-height: $inputHeight;
          font-size: 12px;
          &::placeholder {
            color: $inputColor;
          }
        }
      }
    }

    .icon-box {
      margin: 18px 10px 0 10px;
      a {
        color: #fff;
        .anticon {
          font-size: 24px;
        }
        .ant-badge-count {
          box-shadow: none;
        }
      }
    }
    .user-info {
      color: #fff;
      margin-top: 16px;
      position: relative;
      .head-icon {
        margin: 0 10px;
        cursor: pointer;
        vertical-align: middle;
        font-size: 30px;
      }

      .head-picture {
        font-size: 30px;
        vertical-align: middle;
      }
      .user-name {
        cursor: pointer;
        display: inline-block;
      }
      .dropDown-box {
        width: 100px;
        position: absolute;
        top: 44px;
        right: 0px;
        z-index: 9;
        .list-item {
          background: #2e77bd;
          width: 100%;
          height: 30px;
          line-height: 30px;
          text-align: center;
          cursor: pointer;
          margin-bottom: 1px;
        }
      }
    }
  }
}
</style>